package cn.tedu.luban.settle.main.repository;

import cn.tedu.luban.settle.main.converter.SettleConverter;
import cn.tedu.luban.settle.main.mapper.SettleMapper;
import cn.tedu.luban.settle.protocol.dos.SettleBillDO;
import cn.tedu.luban.settle.protocol.param.SettleBillParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Slf4j
public class SettleRepoImpl implements SettleRepository{

    @Autowired
    private SettleMapper settleMapper;

    @Autowired
    private SettleConverter settleConverter;

    @Override
    public Long countSettleBillByOrderNo(String orderNo) {
        return settleMapper.countSettleBillByOrderNo(orderNo);
    }

    @Override
    public void batchSave(List<SettleBillParam> params) {
        List<SettleBillDO> dos = settleConverter.params2dos(params);
        settleMapper.batchInsert(dos);
    }
}
